import os  # 与操作系统交互模块
import sys  # 与python解释器和运行环境相关的函数和变量
import django  # django框架模块

# 迭代版（无需更改，要保证此文件是：根目录/scripts/该脚本 即可
cwd = os.getcwd()  # D:\d_pycharm_program\workshop_managerment\scripts
root_path = os.path.dirname(cwd)  # D:\d_pycharm_program\workshop_managerment
root = os.path.basename(root_path)  # workshop_managerment

base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))  # D:\d_pycharm_program\workshop_managerment
sys.path.append(base_dir)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', f'{root}.settings')
django.setup()

# 脚本代码
# from pathlib import Path
# print(__file__)
# print(Path(__file__).resolve().parent)
# print(Path(__file__).resolve().parent.parent)'


# if not 1 == 2:
#     print(1)


# class HttpContent:
#     def __init__(self):
#         self.status = True
#         self.data = None
#         self.error = None
# ctx = HttpContent()
# print(ctx.__dict__)


# 生成测试数据
from www import models
from www.models import PricePolicy

obj_list = []
for i in range(79, 199):
    obj_list.append(PricePolicy(count=(i+1) * 100, price=(i+1) * 10))

models.PricePolicy.objects.bulk_create(obj_list)